package com.jiage.middlec;

import android.content.Context;

import com.jiage.sp.SDSpManager;

import java.util.Map;

public class Middle {
    /**
     * 初始化
     * @param context
     */
    public void init(Context context){
        SDSpManager.getInstance().init(context);
    }
    /**
     * 初始化
     * @param context
     * @param name
     */
    public void init(Context context,String name){
        SDSpManager.getInstance().init(context,name);
    }
    /**
     * 存储
     */
    public void put(String key, Object object){
        SDSpManager.getInstance().put(key, object);
    }
    /**
     * 获取保存的数据
     */
    public Object get(String key, Object defaultObject){
        return SDSpManager.getInstance().get(key, defaultObject);
    }
    public void putString(String key, String value){
        SDSpManager.getInstance().putString(key, value);
    }

    public void putInt(String key, int value){
        SDSpManager.getInstance().putInt(key, value);
    }

    public void putBoolean(String key, boolean value){
        SDSpManager.getInstance().putBoolean(key, value);
    }

    public void putFloat(String key, float value){
        SDSpManager.getInstance().putFloat(key, value);
    }

    public void putLong(String key, long value){
        SDSpManager.getInstance().putLong(key, value);
    }

    public String getString(String key, String defaultObject){
        return SDSpManager.getInstance().getString(key, defaultObject);
    }
    public String getString(String key){
        return SDSpManager.getInstance().getString(key);
    }
    public int getInt(String key, int defaultObject){
        return SDSpManager.getInstance().getInt(key, defaultObject);
    }
    public int getInt(String key){
        return SDSpManager.getInstance().getInt(key);
    }
    public boolean getBoolean(String key, boolean defaultObject){
        return SDSpManager.getInstance().getBoolean(key, defaultObject);
    }
    public boolean getBoolean(String key){
        return SDSpManager.getInstance().getBoolean(key);
    }
    public long getLong(String key, long defaultObject){
        return SDSpManager.getInstance().getLong(key, defaultObject);
    }
    public long getLong(String key){
        return SDSpManager.getInstance().getLong(key);
    }
    public float getFloat(String key, float defaultObject){
        return SDSpManager.getInstance().getFloat(key, defaultObject);
    }
    public float getFloat(String key){
        return SDSpManager.getInstance().getFloat(key);
    }

    /**
     * 移除某个key值已经对应的值
     */
    public void remove(String key) {
        SDSpManager.getInstance().remove(key);
    }

    /**
     * 清除所有数据
     */
    public void clear() {
        SDSpManager.getInstance().clear();
    }

    /**
     * 查询某个key是否存在
     */
    public Boolean contain(String key) {
        return SDSpManager.getInstance().contain(key);
    }

    /**
     * 返回所有的键值对
     */
    public Map<String, ?> getAll() {
        return SDSpManager.getInstance().getAll();
    }
}
